package sv.gob.mh.dgii.dao.rc;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;
import sv.gob.mh.dgii.common.Utils;
import sv.gob.mh.dgii.dao.hibernate.HibernateDaoImpl;
import sv.gob.mh.dgii.model.RcRepresentante;
import sv.gob.mh.dgii.model.RcRepresentanteTmp;

@Repository
public class RcRepresentanteDaoImpl extends HibernateDaoImpl implements RcRepresentanteDao {
	
	Log log = LogFactory.getLog(RcRepresentanteDaoImpl.class);
	
	public final String _NIT = "rcRucByNit.nit";
	public final String _FFIN = "ffrepresentante";
	public final String _FHINGRESO = "fhingreso";
	public final String _C_REPRESENTANTE = "tbRepresentante.crepresentante";
	
	public RcRepresentanteDaoImpl(){
		super(RcRepresentante.class); 
	} 

    @Override
    public List<RcRepresentante> obtenerRepresentantesPorNit(String nit) {
        String jpql = "SELECT rep FROM RcRepresentante rep LEFT JOIN FETCH rep.tbRepresentante  where rep.rcRucByNit.nit=:nit ";
        Query q = getSessionFactory().getCurrentSession().createQuery(jpql);
        q.setParameter("nit", nit);
        return q.list();
    
    }
}